Skip to content

Keep Kibana's dashboards through a snapshot restore and a rebuild (S-024-10, S-024-11) - #613

Merged
shipmill-romamo[bot] merged 2 commits into
mainfrom
feat/580-kibana-dashboards-survive
Nov 24, 2026
Merged

shipmill-romamo[bot] merged 2 commits into
mainfrom
feat/580-kibana-dashboards-survive

Conversation

@shipmill-romamo

@shipmill-romamo shipmill-romamo Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Plan

  • Serves: G-1, G-3
  • Files: docs/kibana-service-guide.md (new), engine/tests/test_s024_10_11_kibana_dashboards.py (new), sdk/tests/test_s024_11_kibana_rebuild_keys.py (new), engine/tests/test_s012_elasticsearch_snapshots.py, changelog.d/580-kibana-dashboards-survive.md
  • Order: (1) the Kibana guide gains where the dashboards are backed up, the restore steps and what a rebuilt server gets (spec 024, Saved objects and backups, Connection to the cluster, What the server needs); (2) S-012's fake node can list a snapshot's feature states; (3) tests per criterion; (4) changelog fragment. The backup script, the Elasticsearch role and services.yml stay as on main: the kind has no backup of its own
  • Proof: S-024-10: S-012's backup script, rendered as for any cluster, run against the fake node: its snapshot request asks for the cluster state with no feature_states list (every feature state), and the snapshot it took is listed with the feature state kibana on a node that has it; the guide's three restore commands parsed and checked against the restore API's body. S-024-11: the Kibana role's keystore tasks run for real on a converged host and then on a rebuilt empty one (same three keys from the store, new token, second converge changed=0), and the controller staging the store's keys on every converge while the store never replaces a held key
  • Tests changed: engine/tests/test_s012_elasticsearch_snapshots.py: its fake node gains feature_states, listed on a new snapshot only when a test sets them, so the S-024-10 tests can list a snapshot as a node with Kibana does; S-012's own tests are unchanged and still pass

Summary

Builds S-024-10 and S-024-11 of spec 024: Kibana's dashboards survive a feature-state restore and a rebuilt server. No engine or SDK code changes: what the spec asks already holds on main, and this PR documents and proves it.

  • The feature state kibana in every snapshot (S-024-10): S-012's snapshot asks for the cluster state (include_global_state: true) with no feature_states list, which Elasticsearch takes as every feature state, so once Kibana has started against the cluster each snapshot lists kibana. The request stays exactly as it is (naming kibana would drop the other feature states), and S-012's restore drill (renamed copies of data indices, include_global_state: false) is untouched. As the spec says, the kind has no backup of its own, so cloudfall backup run adds no Kibana check
  • The restore steps: the new docs/kibana-service-guide.md gives them as the spec says: systemctl stop kibana.service, POST /_snapshot/cloudfall/<snapshot>/_restore with {"indices": "-*", "include_global_state": false, "feature_states": ["kibana"]} (no data index, no cluster state, Kibana's system indices replaced by the snapshot's), systemctl start kibana.service. It also shows how to read a snapshot's feature states, and asks for the cloudfall password interactively rather than putting it on the command line
  • A rebuilt server (S-024-11): Converge Kibana on a node of its cluster, with its token and keys (S-024-3, S-024-4, S-024-5) #598 already stages the keys from the project's store on every converge, the store never overwrites a held key, and the role puts the staged keys and makes no key on the host. The guide says so, and that the rebuilt node gets a new elastic/kibana token in its own service_tokens file; the old token lived only in the old node's file, so it is valid nowhere once the server is rebuilt (the spec: "a rebuilt server gets a new one")

The guide holds these sections only; its status line says the others the spec lists (declaration, users, Domain, SSH forward, version change, licences) come later.

Test notes

  • New: engine/tests/test_s024_10_11_kibana_dashboards.py (5 tests): S-012's rendered backup script against the fake node, its snapshot request carrying no feature_states list, and the taken snapshot read back with GET /_snapshot/cloudfall/<name> listing kibana and security; the guide's stop, restore and start commands in order, the restore URL and its JSON body; and the Kibana role's keystore.yml run for real with ansible-playbook on a first host and on a rebuilt empty one: the rebuilt keystore holds the store's three keys (the same as the first host's), a new token in the rebuilt node's service_tokens, no secret in the -vvv --diff output, and a second converge changed=0
  • New: sdk/tests/test_s024_11_kibana_rebuild_keys.py (2 tests): two converges stage the same three key values from the store and leave the store file byte-identical; the store refuses to generate over each held key
  • specs.py coverage --spec 024 lists tests for S-024-10 and S-024-11
  • Ran locally: ruff check ., mypy, ansible-lint engine/ansible (with ANSIBLE_CONFIG=engine/ansible/ansible.cfg, as CI), cloudfall config validate --project config/examples, and pytest on the new files plus engine/tests/test_s012_elasticsearch_snapshots.py. The full suite is left to CI

Unverified live (needs Debian 13 hosts with Elastic's packages):

  • a real snapshot of a cluster with Kibana listing feature_states with kibana, and the guide's restore bringing back a deleted dashboard of S-024-6
  • a rebuilt Kibana server: analyst logging in and the dashboard of S-024-6 opening, with saved objects encrypted before the rebuild still decrypting
  • kibana.service starting cleanly after its system indices were replaced by the restore

Fixes #580

🤖 Generated with Claude Code

…024-10, S-024-11)

S-012's snapshots already hold every feature state; with a Kibana service
reading the cluster, the backup script now also checks that the snapshot
it took lists the feature state kibana and fails the run when it does
not, so a backup that would not bring the dashboards back is never
reported as one that does. The snapshot request is unchanged, and the
script of a cluster without Kibana renders byte-identical.

The new Kibana service guide gives the restore (stop Kibana, restore the
feature state kibana alone, start Kibana) and what a rebuilt Kibana
server gets: the store's three encryption keys, never new ones, and a new
token in the rebuilt node's own service_tokens file. Tests prove both on
stand-ins.

Fixes #580

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spec 024 gives Kibana no backup of its own: the S-012 snapshot already asks
for the cluster state and every feature state. Failing cloudfall backup run
when a declared Kibana's feature state is missing, also for a Kibana that
never started, went beyond the spec, so the backup script, the role's
variables and services.yml are back to main's. S-024-10 is now proved by
the snapshot request asking for every feature state and the taken snapshot
listing kibana on a node that has it; the guide and the changelog follow.

Part of #580

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@shipmill-romamo shipmill-romamo Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE. Reviewed inline by the landing session at head 6520df9; no fix commits.

After the revision the PR has no engine or SDK code: the guide docs/kibana-service-guide.md (restore and rebuild sections), a changelog fragment, two new test files, and an opt-in feature_states field on S-012's fake node.

Checked:

  • The restore body {"indices": "-*", "include_global_state": false, "feature_states": ["kibana"]} is Elastic's documented way to restore one feature state alone; Kibana is stopped first and started after (spec 024, Saved objects and backups)
  • The guide uses the cloudfall account with curl prompting for the password; elastic stays break-glass and unused (spec 024)
  • S-012's snapshot request is unchanged, and the test asserts it carries no feature_states list (every feature state)
  • S-024-11: the keys come from the store, are never generated on the server, and a rebuilt empty host gets the same three keys and a new token; a second converge changes nothing
  • The S-012 fake's new field defaults to empty, so S-012's tests are unchanged

Tests run locally: pytest on engine/tests/test_s024_10_11_kibana_dashboards.py, engine/tests/test_s012_elasticsearch_snapshots.py and sdk/tests/test_s024_11_kibana_rebuild_keys.py: 36 passed. The implementer ran ruff, mypy, ansible-lint and config validate. Full suite left to CI.

Unverified live: a real snapshot listing kibana, the restore bringing back a deleted dashboard, and analyst opening it after a rebuild.

Findings not fixed:

  • F-1 nit: the guide covers only backup, restore and rebuild; the spec's other guide sections come with #582

@shipmill-romamo
shipmill-romamo Bot merged commit 785d7a0 into main Nov 24, 2026
3 checks passed
@shipmill-romamo
shipmill-romamo Bot deleted the feat/580-kibana-dashboards-survive branch November 24, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kibana service: dashboards survive a snapshot restore and a rebuilt server (S-024-10, S-024-11)

0 participants